package com.example.chat.controller;

import com.example.chat.pojo.Goods;


import com.example.chat.service.GoodsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j
@RestController
@CrossOrigin(origins = "http://localhost:8080")
public class ApiController {

    @Autowired
    private GoodsService goodsService;



    @GetMapping("/api/goods")
    public List<Goods> getGoods() {
        log.info("Received request to fetch all goods.");
        return goodsService.getAllGoods();
    }
}
